import mathprint(math.sqrt(25))
Output
5.0
| Term | Meaning |
|---|---|
| Module | One small handleable unit of code, usually a single file |
| Library | A collection of modules that serve one type of need |
| Package | A container holding various functions and modules for specific tasks |
Packages keep code reusable. You reach inside one with the
import statement and the dot operator.
import module1[, module2, ... moduleN]
import mathprint(math.sqrt(25))
5.0
You have to write module_name.function_name() to reach
anything inside.
from math import sqrtprint(sqrt(25))
5.0
No need to prefix withmath.when callingsqrt()this way.
import datetime as dtprint(dt.datetime.now())
2026-09-21 14:05:37.412908
dtis just a shorthand fordatetime, handy for long module names.
from math import *print(sin(90))
0.8939966636005579
The answer looks odd because sin() expects radians, not
degrees.